package cn.yudao.basic.service.impl;

import cn.yudao.basic.dto.ExitDto;
import cn.yudao.basic.exception.BusinessException;
import cn.yudao.basic.service.IExitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
public class ExitServiceImpl implements IExitService {
    @Autowired
    private RedisTemplate redisTemplate;


    /**
    * @Title: exit
    * @Description: 退出业务实现类
    * @Author: Mr.Jia
    * @Version: 1.0
    * @Date:  2022/7/8 22:52
    * @Parameters:
    * @Return
    */
    @Override
    public void exit(ExitDto exitDto) {
        if (exitDto == null){
            throw new BusinessException("退出失败！");
        }
        String logininfo = exitDto.getLogininfo();
        String token = exitDto.getToken();
        if (StringUtils.isEmpty(token) || StringUtils.isEmpty(logininfo)){
            throw new BusinessException("退出失败！");
        }
        redisTemplate.delete("token");
        redisTemplate.delete("logininfo");
    }
}
